package com.webapi.core.servlet;

import java.io.IOException;
import java.io.Writer;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.webapi.common.utils.Parameters;
import com.webapi.core.service.FacadeService;

@Component
public class InitParameters extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	@Autowired
	private FacadeService facadeService;
	
    public InitParameters() {
        super();
    }

	@Override
	public void init() throws ServletException {
		super.init();
		Parameters.INSTANCE.init(facadeService);
	}
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		init();
		Writer out = response.getWriter();
		out.write("reload success");
		out.close();
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
	
}
